package org.carl.base.dingtalk.bot.model.markdown;


import cn.hutool.json.JSONUtil;
import lombok.Getter;
import org.carl.base.dingtalk.bot.enums.MsgTypeEnum;
import org.carl.base.dingtalk.bot.model.At;
import org.carl.base.dingtalk.bot.model.MsgModel;

/**
 * @author Carl
 */
@Getter
public class MarkdownMsgModel extends MsgModel {
    private MarkdownMsgModel() {
        msgtype = MsgTypeEnum.markdown;
    }

    /**
     * 创建一个text对象
     *
     * @param markdown MarkdownModel
     * @return
     */
    public static MarkdownMsgModel markdown(MarkdownModel markdown) {
        MarkdownMsgModel markdownMsgModel = new MarkdownMsgModel();
        markdownMsgModel.markdown = markdown;
        markdownMsgModel.at = new At();
        return markdownMsgModel;
    }

    /**
     * 创建一个MarkdownModel和at对象
     *
     * @param markdown MarkdownModel
     * @param at       At
     * @return MarkdownMsgModel
     */
    public static MarkdownMsgModel markdownAndAt(MarkdownModel markdown, At at) {
        MarkdownMsgModel textMsgModel = markdown(markdown);
        textMsgModel.at = at;
        return textMsgModel;
    }

    /**
     * 被@的对象 需要传手机号
     */
    private At at;

    private MarkdownModel markdown;


    @Override
    public String toString() {
        return JSONUtil.toJsonStr(this);
    }
}
